package com.chhh.cranelease.controller.baseinfocontroller;

import com.chhh.cranelease.entity.Staff;
import com.chhh.cranelease.model.DriverInfoModel;
import com.chhh.cranelease.model.ResponseCode;
import com.chhh.cranelease.service.BaseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("driver/")
public class DriverInfoController {

    @Autowired
    private BaseInfoService baseInfoService;

    private ResponseCode responseCode = new ResponseCode();

    @RequestMapping("selectAllDriver")
    public List<DriverInfoModel> selectAllDriver(String  s_card, String s_name, String s_sex, String s_intime, String s_outtime){
       return baseInfoService.selectAllDriver(s_card,s_name,s_sex,s_name,s_intime,s_outtime);
    }

    @RequestMapping("insertDriver")
    public ResponseCode insertDriver(Staff staff){
       Integer driverNum = baseInfoService.insertNewDriver(staff);
       responseCode.setErrorCode(0);
       responseCode.setStatus("你插入了"+driverNum+"条数据");
       return responseCode;
    }
    @RequestMapping("updateDriver")
    public ResponseCode updateDriver(Staff staff){
        Integer driverUpdateNum = baseInfoService.updateThisDriver(staff);
        responseCode.setErrorCode(0);
        responseCode.setStatus("你更新了"+driverUpdateNum+"条数据");
        return responseCode;
    }
}
